package com.iscreen.core.services.flow;

import java.io.Serializable;

import com.iscreen.utils.exceptions.IScreenException;

public abstract class Flow
{
	protected FlowType flowType; 

	protected Flow(FlowType flowType)
	{
		this.flowType = flowType;
	}

	protected abstract void startFlow(Object... params) throws IScreenException;
	
	protected abstract void proceed(StepType currentStep, Object stepResult) throws IScreenException;
	
	protected FlowType getFlowType()
	{
		return flowType;
	}

	protected void sendMessage(StepType nextStep, Serializable message) throws IScreenException
	{
		FlowMessage flowMessage = new FlowMessage(getFlowType(), nextStep, message);
		sendMessage(flowMessage);
	}

	private void sendMessage(FlowMessage flowMessage) throws IScreenException
	{
		FlowService.getInstance().sendMessage(flowMessage);
	}
}
